package com.base.controller;

import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import com.base.po.voip.Adversiments;
import com.base.service.AdversimentsService;

/**
 * 轮播广告信息服务端
 * 
 * @author f 优化日期：10-16
 *
 */
@Controller
@RequestMapping("/admin")
public class CarouselIndexController {

	@Autowired
	private AdversimentsService adversimentsService; // 轮播广告Service

	// 轮播广告首页
	@RequestMapping("/carousel_index")
	public ModelAndView index(HttpSession session) {
		Object obj_id = session.getAttribute("adminUserId"); // 登录的用户ID
		if (obj_id == null) {
			return new ModelAndView("jsp/loginCheck"); // 未登录
		}
		return new ModelAndView("jsp/carousel_index", "adsList",
				adversimentsService.selectByAll(new Adversiments((String) obj_id, true)));
	}

	// 跳转添加轮播
	@RequestMapping("/carousel_add")
	public String add() {
		return "jsp/carousel_add";
	}

	// 跳转修改轮播信息
	@RequestMapping("/carousel_update")
	public ModelAndView update(String id) {
		return new ModelAndView("jsp/carousel_update", "adversiments", adversimentsService.selectByPrimaryKey(id));
	}
}
